<template>
  <div class="projects-more">
     <head-usual :title="title" :to="to"></head-usual>
     <!-- 项目基本情况 -->
     <div class="project-info">
         <div class="info-hd">
             <div class="hd-1">
                 <p class="title">{{project.name}}</p>
                 <p class="price">{{project.price}} 万元</p>
             </div>
             <div class="hd-2">
                 <span>类型：</span>
                 <span>{{project.type}}</span>
             </div>
             <div class="hd-3">
                 <p>
                     <span>周期：</span>
                     <span>{{project.duration}}</span>
                 </p>
                 <p>
                     <span>{{project.addtime}}</span>
                     <span>发布于筑功者</span>
                 </p>
             </div>

         </div>
         <div class="info-ft">
             <div class="title">
                 项目职责：
             </div>
             <p class="ft-html" v-html="project.description">

             </p>
             <!-- <router-link class="learn-more" :to=" '/projects/detail/' +project.id">了解更多</router-link> -->
         </div>
     </div>
     <div class="select-menu">
         <mt-navbar v-model="status">
            <mt-tab-item id="1">候选人</mt-tab-item>
            <mt-tab-item id="3">确认合作</mt-tab-item>
            <mt-tab-item id="4">不合适</mt-tab-item>
        </mt-navbar>
     </div>
<!-- tab-container -->
        <mt-tab-container v-model="status" swipeable>
            <mt-tab-container-item id="1">
                <!-- 候选人 -->
                <div class="candidate">
                    <div class="candidate-item" v-for="(item,index) in memberList" :key="index">
                        <dl>
                        <dt>
                             <router-link :to="(item.type=='个人用户'?'/m/':'/c/')+item.id">
                                <img :src="item.headportrait"/>
                             </router-link>
                        </dt>
                        <dd>
                            <p class="dd-p1">
                                <span class="p1-name chaochu1">{{item.name}}</span>
                                <span class="fenge"></span>
                                <span class="p1-name chaochu">{{item.industry}}</span>
                                <span class="p1-slogan">{{item.type}}</span>
                            </p>
                            <p class="dd-p2">
                                <span v-for="(tag,index) in item.Arr_tags" :key="index">{{tag}}</span>
                            </p>
                            <p class="dd-p3">
                                <span>参与理由：</span>
                                <span>{{item.Qualified}}</span>
                                <span class="read-more" @click="readMore(item.Qualified)">查看更多</span>
                            </p>
                        </dd>
                        </dl>
                        <div class="item-edit">
                            <div class="edit-left" @click="CandidateHandle(item.id,index,3)">确认合作</div>
                            <p class="fenge"></p>
                            <div @click="CandidateHandle(item.id,index,4)">不合适</div>
                        </div>
                    </div>
                </div>
            </mt-tab-container-item>
            <mt-tab-container-item id="3">
               <div class="candidate">
                    <div class="candidate-item" v-for="(item,index) in memberList" :key="index">
                        <dl>
                        <dt>
                                 <router-link :to="(item.type=='个人用户'?'/m/':'/c/')+item.id">
                                <img :src="item.headportrait"/>
                             </router-link>
                        </dt>
                        <dd>
                            <p class="dd-p1">
                                <span class="p1-name chaochu1">{{item.name}}</span>
                                <span class="fenge"></span>
                                <span class="p1-name chaochu">{{item.industry}}</span>
                                <span class="p1-slogan">{{item.type}}</span>
                            </p>
                            <p class="dd-p2">
                                <span v-for="(tag,index) in item.Arr_tags" :key="index">{{tag}}</span>
                            </p>
                            <p class="dd-p3">
                                <span>参与理由：</span>
                                <span>{{item.Qualified}}</span>
                                <span class="read-more" @click="readMore(item.Qualified)">查看更多</span>
                            </p>
                        </dd>
                        </dl>
                    </div>
                </div>
            </mt-tab-container-item>
            <mt-tab-container-item id="4">
                <div class="candidate">
                    <div class="candidate-item" v-for="(item,index) in memberList" :key="index">
                        <dl>
                        <dt>
                            <router-link :to="(item.type=='个人用户'?'/m/':'/c/')+item.id">
                                <img :src="item.headportrait"/>
                             </router-link>
                        </dt>
                        <dd>
                            <p class="dd-p1">
                                <span class="p1-name chaochu1">{{item.name}}</span>
                                <span class="fenge"></span>
                                <span class="p1-name chaochu">{{item.industry}}</span>
                                <span class="p1-slogan">{{item.type}}</span>
                            </p>
                            <p class="dd-p2">
                                <span v-for="(tag,index) in item.Arr_tags" :key="index">{{tag}}</span>
                            </p>
                            <p class="dd-p3">
                                <span>参与理由：</span>
                                <span>{{item.Qualified}}</span>
                                <span class="read-more" @click="readMore(item.Qualified)">查看更多</span>
                            </p>
                        </dd>
                        </dl>
                    </div>
                </div>
            </mt-tab-container-item>
        </mt-tab-container>
        <!-- 点击查看更多弹出框 -->
        <mt-popup v-model="popupMore" popup-transition="popup-fade" class="read-popup">
                <p class="project-view">项目通知</p>
                <p class="detail">{{popupTipText}}</p>
        </mt-popup>
        </div>
</template>

<script>
import { Navbar, TabItem, MessageBox } from "mint-ui";
import { Candidate, ConfirmCooperation } from "@/api/user/project";
export default {
  data() {
    return {
      title: "我的项目",
      to: "/user/project",
      id: 0,
      status: "1",
      project: "",
      memberList: "",
      popupMore: false,
      popupTipText: "115"
    };
  },
  created() {
    this.id = parseInt(this.$route.params.id);
    this.Initialization();
  },
  methods: {
    readMore(info) {
      this.popupMore = true;
      this.popupTipText = info;
      // console.log(info);
    },
    CandidateHandle(uid, index, status) {
      var msg =
        status == 3 ? "你确定要其加入项目吗？？" : "是否认为他不合适？？";
      MessageBox.confirm(msg).then(action => {
        ConfirmCooperation(uid, this.id, status).then(res => {
          if (res.StatusCode === 200 && res.Data) {
            //
            this.memberList.splice(this.index, 1);
          } else {
            this.$toast("操作失败请刷新重试");
          }
        });
      });
    },
    Initialization() {
      this.$indicator.open();
      setTimeout(() => {
        Candidate(this.id, this.status).then(res => {
          if (res.StatusCode === 200) {
            this.project = res.Data.Project;
            this.memberList = res.Data.Members;
            this.$indicator.close();
          }
        });
      }, 100);
    }
  },
  watch: {
    status(val, oldVal) {
      this.Initialization();
    }
  }
};
</script>

<style lang="scss" scoped>
// 项目基本情况
.project-info {
  padding: 17px 12px 0 12px;
  border-bottom: 10px solid #f4f4f4;
  .info-hd {
    .hd-1 {
      display: flex;
      justify-content: space-between;
      .title {
        font-size: 16px;
        color: #282828;
      }
      .price {
        font-size: 16px;
        color: #fd4f00;
      }
    }
    .hd-2 {
      font-size: 14px;
      margin-top: 13px;
      color: #666666;
    }
    .hd-3 {
      margin-top: 10px;
      display: flex;
      justify-content: space-between;
      font-size: 14px;
      color: #666666;
      padding-bottom: 12px;
      border-bottom: 1px dashed #f4f4f4;
    }
  }
  .info-ft {
    padding: 12px 12px;
    .title {
      font-size: 16px;
      color: #282828;
    }
    .ft-html {
      margin-top: 10px;
      font-size: 14px;
      color: #666666;
    }
    .learn-more {
      color: #3887fe;
      text-decoration: underline;
      text-align: right;
      font-size: 14px;
      display: block;
    }
  }
}
.select-menu {
  margin-left: 12px;
  border-bottom: 1px solid #f4f4f4;
  .mint-navbar {
    margin-top: 16px;
    width: 180px;
    margin-right: 12px;

    .mint-tab-item {
      color: #666666;
    }
    .mint-tab-item.is-selected {
      border-bottom: 2px solid #fd4f00;
      color: #fd4f00;
      margin-bottom: -2px;
    }
  }
}
.candidate {
  .candidate-item {
    border-bottom: 10px solid #f4f4f4;
    dl {
      margin-top: 39.3px;
      margin-left: 12px;
      margin-right: 12px;
      display: flex;

      dt {
        width: 75px;
        height: 75px;
        img {
          max-width: 100%;
          max-height: 100%;
          vertical-align: middle;
        }
      }
      dd {
        margin-left: 12px;
        .dd-p1 {
          display: flex;
          align-items: center;
          .p1-name {
            font-size: 16px;
            color: #282828;
          }
          .chaochu1{
               width: 65px;
            overflow: hidden;
            text-overflow:ellipsis;
            white-space: nowrap;
          }
          .chaochu{
              width: 140px;
            overflow: hidden;
            text-overflow:ellipsis;
            white-space: nowrap;
          }
          .fenge {
            width: 1px;
            height: 15px;
            background: #282828;
            display: block;
            margin: 0 14px;
          }
          .p1-slogan {
            background: #3887fe;
            color: #ffffff;
            margin-left: 13px;
          }
        }
        .dd-p2 {
          margin-top: 12px;
          display: flex;
          span {
            display: block;
            padding: 0 2px;
            border: 1px solid #fd4f00;
            color: #fd4f00;
            margin-right: 10px;
            text-align: center;
          }
        }
        .dd-p3 {
          margin-top: 12px;
          color: #999999;
          font-size: 14px;
          margin-bottom: 12px;
          .read-more {
            color: #3887fe;
          }
        }
      }
    }
    .item-edit {
      height: 44.6px;
      width: 100%;
      line-height: 44.6px;
      display: flex;
      border-top: 1px solid #f4f4f4;

      margin-top: 18px;
      font-size: 16px;
      justify-content: space-between;
      text-align: center;
      align-items: center;
      div {
        width: 50%;
        color: #999999;
      }
      .edit-left {
        color: #3887fe;
      }
      p {
        width: 1px;
        height: 14px;
        background: #999999;
      }
    }
  }
}

// 查看更多弹出框
.read-popup {
  width: 390px;
  border-radius: 5px;
  .project-view {
    height: 37.3px;
    line-height: 37.3px;
    font-size: 16px;
    color: #282828;
    text-align: center;
    border-bottom: 1px solid #f4f4f4;
  }
  .detail {
    margin-top: 16px;
    margin-left: 12px;
    margin-right: 12px;
    font-size: 14px;
    color: #666666;
    text-indent: 2em;
    margin-bottom: 45px;
    line-height: 1.6;
  }
}
</style>
